<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>冒泡排序</title>
  </head>
  <body>
    <script>
      let arr = [2, 1, 3, 5, 4];
      for (let i = 0; i < arr.length - 1; i++) {
        for (let j = 0; j < arr.length - 1 - i; j++) {
          if (arr[j] > arr[j + 1]) {
            let temp = arr[j];
            arr[j] = arr[j + 1];
            arr[j + 1] = temp;
          }
        }
      }
      for (let items of arr) {
        console.log(items);
      }
    </script>
  </body>
</html>
